var express = require("express");
var db2 = require('./db2.js')
var router = express.Router();
var bodyParser = require("body-parser");

//图表
router.get('/list', async function (req, res) {
	let { date, uid } = req.query
	if(uid){
		var sql = `select s.date, s.score, s.total_time, s.paper, u.name as name from score as s, users as u where u.id = s.uid and s.date like '${date}%' and uid = ${uid}`
	}else{
		var sql = `select s.date, s.score, s.total_time, s.paper, u.name as name from score as s, users as u where u.id = s.uid and s.date like '${date}%'`
	}
  let data = await db2.doSql(sql)
  // console.log(data.resultes)
  res.send(JSON.stringify(db2.heal(data.resultes)))
	// res.send(db.succFn(data))
})

module.exports = router;